package com.zhuhao.thinking.in.java.staticdemo;

import lombok.Data;

public class StaticFiledDemo {

    static Mug mug1;
    static Mug mug2;

    static {
        System.out.println("静态代码块只会执行一次");
        mug1 = new Mug(1);
        mug2 = new Mug(2);
    }

    public static void main(String[] args) {
//        StaticFiledDemo staticFiledDemo = new StaticFiledDemo();
//        StaticFiledDemo staticFiledDemo2 = new StaticFiledDemo();
//
//        Mug mug11 = staticFiledDemo.mug1;
//        Mug mug12 = staticFiledDemo2.mug1;
//        System.out.println(mug11 == mug12);

        Mug mug11 = StaticFiledDemo.mug1;
        System.out.println(mug11);
    }


}

class Mug{
    public Mug(int num) {
        System.out.println(num);
    }

    void f(int num){
        System.out.println("f(" + num + ")");
    }

}
